﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections;

namespace Greyhound
{
    class HTML_TagControl
    {
        public List<HTML_Tag> Storage = new List<HTML_Tag>();
        public HTML_TagControl()
        {
            Storage.Add(new HTML_Tag("html",false));
            Storage.Add(new HTML_Tag("head", false));
            Storage.Add(new HTML_Tag("title", false));
            Storage.Add(new HTML_Tag("body", false));
            Storage.Add(new HTML_Tag("i", false));
        }
        public void setSwitch(String s)
        {
            HTML_Tag Tag = findTag(s);
            if (Tag == null)
            {
                return;
            }
            if (Tag.getStatus() == false)
            {
                Tag.setStatus(true);
            }
            else
            {
                Tag.setStatus(false);
            }
            var i = Storage.FindIndex(x => x.getName() ==Tag.getName());
            Storage[i] = Tag;
        }

        public HTML_Tag findTag(String name)
        {
            foreach (HTML_Tag element in Storage)
            {
                if (element.getName() == name)
                {
                    return element;
                }
            }
            return null;
        }
        public List<HTML_Tag> activeTags()
        {
            List<HTML_Tag> liste = new List<HTML_Tag>();
            foreach (HTML_Tag element in Storage)
            {
                if (element.getStatus() == true)
                {
                    liste.Add(element);
                }
            }
            return liste;
        }
    }
}
